/* eslint-disable */
import vue from 'vue'
import Loading from './Loading.vue'

const LoadingConstructor = vue.extend(Loading)

const loadDom = new LoadingConstructor({
  el: document.createElement('div'),
  data () {
    return {
      text: '',
      show: false
    }
  }
})

document.body.appendChild(loadDom.$el)

const $loading = {
  show (text) {
    if (text) {
      loadDom.text = text
    }
    loadDom.show = true
  },

  hide () {
    if (loadDom.text !== '') {
      loadDom.text = ''
    }
    loadDom.show = false
  }
}

export default function install (Vue) {
  Vue.prototype.$loading = $loading
}
